package com.hpeu_12.day1231;

public class InstanceofDemo {
	public static void main(String[] args) {
		Person p1 = new Student();//多态
		Person p2 = new Person();
		Student s1 = new Student();
		System.out.println(p1 instanceof Student);//true.这是使用到了多态，父类类型的引用指向了子类对象
		System.out.println(p1 instanceof Person);//true
		System.out.println(p2 instanceof Student);//false
		System.out.println(s1 instanceof Person);//true 因为student是Person的子类
	}
}
class Person{
	
}
class Student extends Person{
	
}
class Teacher extends Person{
	
}